home *** CD-ROM | disk | FTP | other *** search
- /* GetPABFSSpecCB.c */
- /*
- * GetPABFSSpecCB.c
- * Copyright © 1992-93 Apple Computer Inc. All Rights Reserved.
- *
- * This is a callback function that AddDirectory uses to build a FSSpec that
- * specifies the requested personal address catalog. Note that it must be called
- * at a time when memory may be allocated.
- */
- #include "DTSSampleCSAM.h"
-
- pascal Boolean
- GetPABFSSpecCB(
- FSSpec *pabSpec,
- const Attribute *thisAttribute
- )
- {
- OSErr status;
- AliasHandle alias;
- Boolean wasChanged;
- THz oldZone;
-
- alias = NULL;
- status = (pabSpec != NULL) ? noErr : nilHandleErr;
- LogStatusX('GPAB', status, "\pNull pabSpec handle");
- if (status == noErr
- && thisAttribute->value.tag != typeBinary) {
- status = paramErr;
- Audit(
- GetAuditPtr(kCSAMCreatorID),
- 'GPAB',
- AuditFormat2(kAuditFormatHex, kAuditFormatString),
- thisAttribute->value.tag,
- "\pNeed binary attribute"
- );
- }
- if (status == noErr) {
- Audit(
- GetAuditPtr(kCSAMCreatorID),
- 'Pt2H',
- AuditFormat3(
- kAuditFormatUnsigned,
- kAuditFormatAddress,
- kAuditFormatString
- ),
- thisAttribute->value.dataLength,
- &alias,
- "\pPtrToHand"
- );
- /*
- * We need a blob of temporary memory for
- * ResolveAlias: make sure it's in the
- * system heap; otherwise we can get
- * a memFull error.
- */
- oldZone = GetZone();
- SetZone(SystemZone());
- LogStatusX('Zone', MemError(), "\pSetZone(SystemZone))");
- status = PtrToHand(
- thisAttribute->value.bytes,
- (Handle *) &alias,
- thisAttribute->value.dataLength
- );
- SetZone(oldZone);
- LogStatusX('Zone', MemError(), "\pSetZone(oldZone))");
- if (status != noErr) {
- Audit(
- GetAuditPtr(kCSAMCreatorID),
- 'GPAB',
- AuditFormat3(
- kAuditFormatSigned,
- kAuditFormatUnsigned,
- kAuditFormatString
- ),
- (signed long) status,
- thisAttribute->value.dataLength,
- "\pPtrToHand"
- );
- }
- }
- if (status == noErr) {
- Audit(GetAuditPtr(kCSAMCreatorID), 'GPAB', kAuditFormatString, "\pResolving Alias");
- status = ResolveAlias(NULL, alias, pabSpec, &wasChanged);
- LogStatusX('GPAB', status, "\pResolveAlias");
- }
- if (alias != NULL) {
- DisposHandle((Handle) alias);
- if (status == noErr) {
- status = MemError();
- LogStatusX('GPAB', status, "\pDisposHandle");
- }
- }
- /*
- * What do we do with status? It's all dressed up with
- * nowhere to go.
- */
- if (status != noErr)
- pabSpec->vRefNum = 0;
- Audit(
- GetAuditPtr(kCSAMCreatorID),
- 'GPAB',
- AuditFormat2(
- kAuditFormatSigned,
- kAuditFormatString
- ),
- (signed long) pabSpec->vRefNum,
- "\pvRefNum (0 bad)"
- );
- return (TRUE);
- }
-